{include file="public/header" /}
</head>
<body style="padding: 20px;">
<from class="layui-form">
    <div class="layui-inline" style="width:400px;">
        <input type="text" class="layui-input" name="keyword" autocomplete="off" placeholder="请输入设计师进行搜索">
    </div>
    <button class="layui-btn" type="button" lay-submit lay-filter="menu_search" id="reloadBtn"><i class="layui-icon">&#xe615;</i> 搜索</button>
</from>
<table class="layui-hide" id="LAY_table_menu" lay-filter="menu"></table>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="choice"><i class="layui-icon">&#xe605;</i>绑定&ensp;</a>
</script>
<script>
    layui.use(['table'], function(){
        var table = layui.table,form = layui.form;
        form.render();
        //监听工具条
        table.on('tool(menu)', function(obj){
            var data = obj.data;
            if(obj.event === 'choice'){
                parent.$('input[name=crm_designer_id]').val(data.user_id);
                parent.$('input[name=designer_name]').val(data.nick_name);
                parent.$('input[name=designer_tel]').val(data.tel);
                parent.$('textarea[name=introduce]').val(data.personal_introduction);
                parent.$('input[name=designer_design_case]').val(data.designer_design_case);
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                parent.layer.close(index); //再执行关闭
            }
        });
        //方法级渲染
        table.render({
            elem: '#LAY_table_menu'
            ,url: '{:url("Designers/bindingDesigner",["table"=>1])}'
            ,cellMinWidth: 80
            ,height: 'full-100'
            ,cols: [[
                {field:'user_id',title: 'ID',align:'center'}
                ,{field:'nick_name',title: '名称',align:'center'}
                ,{field:'tel',title: '电话',align:'center'}
                ,{field:'personal_introduction',title: '个人介绍',align:'center'}
                ,{title:'操作', toolbar: '#barDemo',align:'center'}
            ]]
            ,id: 'testReload'
            ,page: false
            ,done:function () {

            }
        });
        //搜索重载表格
        form.on('submit(menu_search)', function(data){
            table.reload('testReload', {
                where: data.field,
                page: {
                    curr: 1
                }
            });
            return false;
        });
        $(".layui-form").keydown(function(event){
            var keycode = (event.keyCode ? event.keyCode : event.which);
            if(keycode == '13'){
                //回车触发
                $('#reloadBtn').trigger('click');
            }
        });
    });
</script>
</body>
</html>